﻿using System;
using System.Collections.Generic;
using System.Linq;
using NerdDinnerDataComponent;

namespace NerdDinnerWCFService
{
    internal static class Mapper
    {

        internal static DinnerDTO CreateFrom(DinnerInfo dinnerInfo)
        {
            return new DinnerDTO()
                       {
                           Address = dinnerInfo.Address,
                           ContactPhone = dinnerInfo.ContactPhone,
                           Country = dinnerInfo.Country,
                           Description = dinnerInfo.Description,
                           DinnerId = dinnerInfo.DinnerId,
                           EventDate = dinnerInfo.EventDate,
                           HostedBy = dinnerInfo.HostedBy,
                           Latitude = dinnerInfo.Latitude,
                           Longitude = dinnerInfo.Longitude,
                           Title = dinnerInfo.Title
                       };
        }


        internal static DinnerViewDTO CreateFrom(DinnerViewInfo dinnerViewInfo)
        {
            
            return new DinnerViewDTO()
            {
              
                Description = dinnerViewInfo.Description,
                DinnerId = dinnerViewInfo.DinnerId,
                EventDate = dinnerViewInfo.EventDate,
                NumberOfRSVPs = dinnerViewInfo.NumberOfRSVPs,
                Latitude = dinnerViewInfo.Latitude,
                Longitude = dinnerViewInfo.Longitude,
                Title = dinnerViewInfo.Title,
                
            };
        }

        internal static DinnerInfo CreateFrom(DinnerDTO dinnerInfo)
        {
            return new DinnerInfo()
            {
                Address = dinnerInfo.Address,
                ContactPhone = dinnerInfo.ContactPhone,
                Country = dinnerInfo.Country,
                Description = dinnerInfo.Description,
                DinnerId = dinnerInfo.DinnerId,
                EventDate = dinnerInfo.EventDate,
                HostedBy = dinnerInfo.HostedBy,
                Latitude = dinnerInfo.Latitude,
                Longitude = dinnerInfo.Longitude,
                Title = dinnerInfo.Title
            };
        }

        internal static DinnerDTO[] CreateFrom(IList<DinnerInfo> iList)
        {
            return iList.Select(CreateFrom).ToArray();
        }

        internal static DinnerViewDTO[] CreateFrom(IList<DinnerViewInfo> iList)
        {
            return iList.Select(CreateFrom).ToArray();
        }
    }
}